<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>MySQL锁机制详解 | 技术小馆</title>
    <link rel="stylesheet" href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css">
    <link rel="stylesheet" href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            background-color: #f9fafb;
            color: #1f2937;
            line-height: 1.6;
        }
        h1, h2, h3, h4, h5, h6 {
            font-family: 'Noto Serif SC', serif;
            font-weight: 600;
        }
        .hero-gradient {
            background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
        }
        .card-hover {
            transition: all 0.3s ease;
        }
        .card-hover:hover {
            transform: translateY(-4px);
            box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
        }
        .highlight-text {
            position: relative;
            display: inline-block;
        }
        .highlight-text:after {
            content: '';
            position: absolute;
            bottom: 0.1em;
            left: 0;
            right: 0;
            height: 0.4em;
            background-color: rgba(59, 130, 246, 0.3);
            z-index: -1;
            transform: skew(-12deg);
        }
        .drop-cap:first-letter {
            float: left;
            font-size: 3.5em;
            line-height: 0.8;
            margin: 0.1em 0.1em 0 0;
            color: #3b82f6;
            font-weight: 700;
        }
    </style>
</head>
<body>
    <!-- Hero Section -->
    <section class="hero-gradient text-white py-20 px-4">
        <div class="container mx-auto max-w-5xl">
            <div class="flex flex-col items-center text-center">
                <span class="px-4 py-1 mb-4 bg-white bg-opacity-20 rounded-full text-sm font-medium">数据库知识</span>
                <h1 class="text-4xl md:text-5xl font-bold mb-6 leading-tight">MySQL <span class="highlight-text">锁机制</span> 深度解析</h1>
                <p class="text-xl md:text-2xl opacity-90 max-w-3xl">保障数据一致性与高并发的关键设计</p>
                <div class="mt-8 flex space-x-4">
                    <a href="#content" class="px-6 py-3 bg-white text-blue-700 font-medium rounded-lg hover:bg-opacity-90 transition">开始阅读</a>
                    <a href="http://www.yuque.com/jtostring" class="px-6 py-3 border border-white text-white font-medium rounded-lg hover:bg-white hover:bg-opacity-10 transition">访问技术小馆</a>
                </div>
            </div>
        </div>
    </section>

    <!-- Main Content -->
    <main id="content" class="container mx-auto max-w-5xl px-4 py-12">
        <!-- Introduction -->
        <section class="mb-16">
            <div class="bg-white rounded-xl shadow-md p-8 card-hover">
                <p class="drop-cap text-gray-700 text-lg leading-relaxed">MySQL 中的锁机制是保障数据一致性和并发控制的重要手段。MySQL 支持多种锁类型，以适应不同的并发需求和数据操作场景。这些锁类型通过不同的粒度和方式，帮助数据库管理并发控制，保障数据的一致性。在设计数据库和应用时，需要根据具体的业务需求，选择合适的锁机制，以平衡并发性能和数据一致性。</p>
            </div>
        </section>

        <!-- Content Navigation -->
        <section class="mb-16">
            <h2 class="text-2xl font-bold mb-6 text-gray-800 flex items-center">
                <i class="fas fa-bars mr-3 text-blue-500"></i>锁类型导航
            </h2>
            <div class="grid md:grid-cols-2 lg:grid-cols-3 gap-4">
                <a href="#global-lock" class="bg-white rounded-lg shadow-sm p-6 flex items-start card-hover hover:border-blue-500 border border-transparent transition">
                    <div class="mr-4 text-blue-500 text-2xl">
                        <i class="fas fa-globe"></i>
                    </div>
                    <div>
                        <h3 class="font-bold text-lg mb-1">全局锁</h3>
                        <p class="text-gray-600 text-sm">对整个数据库实例加锁</p>
                    </div>
                </a>
                <a href="#table-lock" class="bg-white rounded-lg shadow-sm p-6 flex items-start card-hover hover:border-blue-500 border border-transparent transition">
                    <div class="mr-4 text-blue-500 text-2xl">
                        <i class="fas fa-table"></i>
                    </div>
                    <div>
                        <h3 class="font-bold text-lg mb-1">表级锁</h3>
                        <p class="text-gray-600 text-sm">对整张表加锁</p>
                    </div>
                </a>
                <a href="#row-lock" class="bg-white rounded-lg shadow-sm p-6 flex items-start card-hover hover:border-blue-500 border border-transparent transition">
                    <div class="mr-4 text-blue-500 text-2xl">
                        <i class="fas fa-grip-lines"></i>
                    </div>
                    <div>
                        <h3 class="font-bold text-lg mb-1">行级锁</h3>
                        <p class="text-gray-600 text-sm">对操作的行加锁</p>
                    </div>
                </a>
                <a href="#intention-lock" class="bg-white rounded-lg shadow-sm p-6 flex items-start card-hover hover:border-blue-500 border border-transparent transition">
                    <div class="mr-4 text-blue-500 text-2xl">
                        <i class="fas fa-sitemap"></i>
                    </div>
                    <div>
                        <h3 class="font-bold text-lg mb-1">意向锁</h3>
                        <p class="text-gray-600 text-sm">配合行级锁的表级锁</p>
                    </div>
                </a>
                <a href="#auto-inc-lock" class="bg-white rounded-lg shadow-sm p-6 flex items-start card-hover hover:border-blue-500 border border-transparent transition">
                    <div class="mr-4 text-blue-500 text-2xl">
                        <i class="fas fa-sort-numeric-up"></i>
                    </div>
                    <div>
                        <h3 class="font-bold text-lg mb-1">自增长锁</h3>
                        <p class="text-gray-600 text-sm">确保自增长字段唯一性</p>
                    </div>
                </a>
                <a href="#gap-lock" class="bg-white rounded-lg shadow-sm p-6 flex items-start card-hover hover:border-blue-500 border border-transparent transition">
                    <div class="mr-4 text-blue-500 text-2xl">
                        <i class="fas fa-expand-alt"></i>
                    </div>
                    <div>
                        <h3 class="font-bold text-lg mb-1">Gap锁与Next-Key锁</h3>
                        <p class="text-gray-600 text-sm">解决幻读问题</p>
                    </div>
                </a>
            </div>
        </section>

        <!-- Visualization -->
        <section class="mb-16">
            <h2 class="text-2xl font-bold mb-6 text-gray-800 flex items-center">
                <i class="fas fa-project-diagram mr-3 text-blue-500"></i>锁机制关系图
            </h2>
            <div class="bg-white rounded-xl shadow-md p-6">
                <div class="mermaid">
                    graph TD
                        A[MySQL锁机制] --> B[按粒度分类]
                        A --> C[按用途分类]
                        B --> D[全局锁]
                        B --> E[表级锁]
                        B --> F[行级锁]
                        C --> G[共享锁(S锁)]
                        C --> H[排他锁(X锁)]
                        C --> I[意向锁(IS/IX)]
                        C --> J[自增长锁]
                        C --> K[Gap锁]
                        C --> L[Next-Key锁]
                        E --> M[读锁(共享)]
                        E --> N[写锁(排他)]
                </div>
            </div>
        </section>

        <!-- Global Lock -->
        <section id="global-lock" class="mb-16">
            <div class="flex items-center mb-6">
                <span class="w-12 h-12 rounded-full bg-blue-100 flex items-center justify-center text-blue-600 text-xl mr-4">
                    <i class="fas fa-globe"></i>
                </span>
                <h2 class="text-2xl font-bold text-gray-800">一、全局锁（Global Lock）</h2>
            </div>
            <div class="bg-white rounded-xl shadow-md overflow-hidden">
                <div class="p-8">
                    <p class="text-gray-700 mb-6">全局锁是对整个数据库实例加锁，通常用于需要对整个数据库进行一致性备份的场景。在 MySQL 中，全局锁可以通过 <code class="px-2 py-1 bg-gray-100 rounded text-red-500">FLUSH TABLES WITH READ LOCK (FTWRL)</code> 命令来实现，它会使得整个数据库处于只读状态。</p>
                    
                    <div class="grid md:grid-cols-2 gap-6 mb-6">
                        <div class="bg-blue-50 rounded-lg p-6 border-l-4 border-blue-500">
                            <h3 class="font-bold text-lg flex items-center mb-3">
                                <i class="fas fa-check-circle mr-2 text-blue-500"></i>应用场景
                            </h3>
                            <ul class="space-y-2">
                                <li class="flex items-start">
                                    <i class="fas fa-database text-blue-400 mt-1 mr-2 text-sm"></i>
                                    <span><strong>备份：</strong>在需要进行一致性备份时，防止在备份过程中有写操作破坏数据的一致性。</span>
                                </li>
                                <li class="flex items-start">
                                    <i class="fas fa-tools text-blue-400 mt-1 mr-2 text-sm"></i>
                                    <span><strong>维护操作：</strong>在某些需要短时间内确保数据库不发生写操作的维护场景中使用。</span>
                                </li>
                            </ul>
                        </div>
                        <div class="bg-orange-50 rounded-lg p-6 border-l-4 border-orange-500">
                            <h3 class="font-bold text-lg flex items-center mb-3">
                                <i class="fas fa-exclamation-triangle mr-2 text-orange-500"></i>影响
                            </h3>
                            <p>使用全局锁期间，所有的写操作都会被阻塞，系统的并发性能会显著下降，因此不建议在高并发环境下长时间使用。</p>
                        </div>
                    </div>
                </div>
            </div>
        </section>

        <!-- Table Lock -->
        <section id="table-lock" class="mb-16">
            <div class="flex items-center mb-6">
                <span class="w-12 h-12 rounded-full bg-green-100 flex items-center justify-center text-green-600 text-xl mr-4">
                    <i class="fas fa-table"></i>
                </span>
                <h2 class="text-2xl font-bold text-gray-800">二、表级锁（Table Lock）</h2>
            </div>
            <div class="bg-white rounded-xl shadow-md overflow-hidden">
                <div class="p-8">
                    <p class="text-gray-700 mb-6">表级锁是在 MySQL 中对整张表加锁，MySQL 提供了多种表级锁，包括共享读锁（<code class="px-2 py-1 bg-gray-100 rounded text-red-500">READ LOCK</code>）和排他写锁（<code class="px-2 py-1 bg-gray-100 rounded text-red-500">WRITE LOCK</code>）。与全局锁相比，表级锁的粒度较细，但仍会对表的所有行产生影响。</p>
                    
                    <div class="grid md:grid-cols-2 gap-6 mb-6">
                        <div class="bg-green-50 rounded-lg p-6 border-l-4 border-green-500">
                            <h3 class="font-bold text-lg flex items-center mb-3">
                                <i class="fas fa-lock-open mr-2 text-green-500"></i>常见的表级锁
                            </h3>
                            <ul class="space-y-3">
                                <li>
                                    <div class="font-medium">读锁（READ LOCK）</div>
                                    <p class="text-sm text-gray-600">也叫共享锁，多个事务可以同时加读锁，互不影响。但加了读锁的表不能进行写操作。</p>
                                </li>
                                <li>
                                    <div class="font-medium">写锁（WRITE LOCK）</div>
                                    <p class="text-sm text-gray-600">也叫排他锁，只有一个事务可以加写锁，并且其他事务不能对表进行读写操作。</p>
                                </li>
                            </ul>
                        </div>
                        <div class="bg-purple-50 rounded-lg p-6 border-l-4 border-purple-500">
                            <h3 class="font-bold text-lg flex items-center mb-3">
                                <i class="fas fa-tasks mr-2 text-purple-500"></i>应用场景
                            </h3>
                            <ul class="space-y-2">
                                <li class="flex items-start">
                                    <i class="fas fa-file-import text-purple-400 mt-1 mr-2 text-sm"></i>
                                    <span><strong>批量导入数据：</strong>在批量插入或更新数据时，可以使用写锁以确保在数据操作完成之前不会有其他读写操作干扰。</span>
                                </li>
                                <li class="flex items-start">
                                    <i class="fas fa-columns text-purple-400 mt-1 mr-2 text-sm"></i>
                                    <span><strong>表结构变更：</strong>在修改表结构时，加表级写锁防止其他事务访问表数据。</span>
                                </li>
                            </ul>
                        </div>
                    </div>
                    
                    <div class="bg-yellow-50 rounded-lg p-6 border-l-4 border-yellow-500">
                        <h3 class="font-bold text-lg flex items-center mb-3">
                            <i class="fas fa-exclamation-triangle mr-2 text-yellow-500"></i>影响
                        </h3>
                        <p>表级锁的范围较大，容易导致锁竞争，尤其是在高并发的环境中，会显著影响系统性能。</p>
                    </div>
                </div>
            </div>
        </section>

        <!-- Row Lock -->
        <section id="row-lock" class="mb-16">
            <div class="flex items-center mb-6">
                <span class="w-12 h-12 rounded-full bg-indigo-100 flex items-center justify-center text-indigo-600 text-xl mr-4">
                    <i class="fas fa-grip-lines"></i>
                </span>
                <h2 class="text-2xl font-bold text-gray-800">三、行级锁（Row Lock）</h2>
            </div>
            <div class="bg-white rounded-xl shadow-md overflow-hidden">
                <div class="p-8">
                    <p class="text-gray-700 mb-6">行级锁是 InnoDB 存储引擎提供的锁机制，它的粒度比表级锁更细，只对操作的行加锁，不影响同一表中其他行的并发操作。行级锁包括共享锁（S 锁）和排他锁（X 锁）。</p>
                    
                    <div class="grid md:grid-cols-2 gap-6 mb-6">
                        <div class="bg-indigo-50 rounded-lg p-6 border-l-4 border-indigo-500">
                            <h3 class="font-bold text-lg flex items-center mb-3">
                                <i class="fas fa-lock mr-2 text-indigo-500"></i>常见的行级锁
                            </h3>
                            <ul class="space-y-3">
                                <li>
                                    <div class="font-medium">共享锁（S 锁）</div>
                                    <p class="text-sm text-gray-600">允许其他事务读取被锁定的行，但不允许修改。</p>
                                </li>
                                <li>
                                    <div class="font-medium">排他锁（X 锁）</div>
                                    <p class="text-sm text-gray-600">禁止其他事务对被锁定的行进行读写操作。</p>
                                </li>
                            </ul>
                        </div>
                        <div class="bg-pink-50 rounded-lg p-6 border-l-4 border-pink-500">
                            <h3 class="font-bold text-lg flex items-center mb-3">
                                <i class="fas fa-random mr-2 text-pink-500"></i>应用场景
                            </h3>
                            <ul class="space-y-2">
                                <li class="flex items-start">
                                    <i class="fas fa-users text-pink-400 mt-1 mr-2 text-sm"></i>
                                    <span><strong>高并发场景：</strong>在需要对表的某些行进行修改时，行级锁可以防止其他事务修改同一行数据，从而保证数据一致性，同时允许其他事务操作其他行。</span>
                                </li>
                                <li class="flex items-start">
                                    <i class="fas fa-user-lock text-pink-400 mt-1 mr-2 text-sm"></i>
                                    <span><strong>悲观锁：</strong>在读取某行数据后，对该行数据加上排他锁，确保接下来对该行数据的修改不会被其他事务干扰。</span>
                                </li>
                            </ul>
                        </div>
                    </div>
                    
                    <div class="bg-blue-50 rounded-lg p-6 border-l-4 border-blue-500">
                        <h3 class="font-bold text-lg flex items-center mb-3">
                            <i class="fas fa-tachometer-alt mr-2 text-blue-500"></i>影响
                        </h3>
                        <p>行级锁能够显著提升并发性能，但它也增加了系统的开销，因为锁的管理变得更加复杂。</p>
                    </div>
                </div>
            </div>
        </section>

        <!-- Intention Lock -->
        <section id="intention-lock" class="mb-16">
            <div class="flex items-center mb-6">
                <span class="w-12 h-12 rounded-full bg-teal-100 flex items-center justify-center text-teal-600 text-xl mr-4">
                    <i class="fas fa-sitemap"></i>
                </span>
                <h2 class="text-2xl font-bold text-gray-800">四、意向锁（Intention Lock）</h2>
            </div>
            <div class="bg-white rounded-xl shadow-md overflow-hidden">
                <div class="p-8">
                    <p class="text-gray-700 mb-6">意向锁是 InnoDB 提供的一种内部使用的表级锁，用于配合行级锁，确保在加行级锁时不会发生锁冲突。意向锁包括意向共享锁（IS 锁）和意向排他锁（IX 锁）。</p>
                    
                    <div class="grid md:grid-cols-2 gap-6 mb-6">
                        <div class="bg-teal-50 rounded-lg p-6 border-l-4 border-teal-500">
                            <h3 class="font-bold text-lg flex items-center mb-3">
                                <i class="fas fa-lock mr-2 text-teal-500"></i>常见的意向锁
                            </h3>
                            <ul class="space-y-3">
                                <li>
                                    <div class="font-medium">意向共享锁（IS 锁）</div>
                                    <p class="text-sm text-gray-600">表示事务准备在某些行上加共享锁。</p>
                                </li>
                                <li>
                                    <div class="font-medium">意向排他锁（IX 锁）</div>
                                    <p class="text-sm text-gray-600">表示事务准备在某些行上加排他锁。</p>
                                </li>
                            </ul>
                        </div>
                        <div class="bg-blue-50 rounded-lg p-6 border-l-4 border-blue-500">
                            <h3 class="font-bold text-lg flex items-center mb-3">
                                <i class="fas fa-cogs mr-2 text-blue-500"></i>应用场景
                            </h3>
                            <p><strong>锁兼容性检查：</strong>意向锁帮助 InnoDB 快速判断是否有必要在整个表上加锁，而无需逐行检查锁冲突情况，从而提高锁定的效率。</p>
                        </div>
                    </div>
                    
                    <div class="bg-gray-50 rounded-lg p-6 border-l-4 border-gray-500">
                        <h3 class="font-bold text-lg flex items-center mb-3">
                            <i class="fas fa-tachometer-alt mr-2 text-gray-500"></i>影响
                        </h3>
                        <p>意向锁对系统性能影响较小，因为它们仅用于优化锁的管理过程，而不直接参与数据访问。</p>
                    </div>
                </div>
            </div>
        </section>

        <!-- Auto-Increment Lock -->
        <section id="auto-inc-lock" class="mb-16">
            <div class="flex items-center mb-6">
                <span class="w-12 h-12 rounded-full bg-red-100 flex items-center justify-center text-red-600 text-xl mr-4">
                    <i class="fas fa-sort-numeric-up"></i>
                </span>
                <h2 class="text-2xl font-bold text-gray-800">五、自增长锁（Auto-Increment Lock）</h2>
            </div>
            <div class="bg-white rounded-xl shadow-md overflow-hidden">
                <div class="p-8">
                    <p class="text-gray-700 mb-6">自增长锁是 InnoDB 在处理自增长字段（<code class="px-2 py-1 bg-gray-100 rounded text-red-500">AUTO_INCREMENT</code>）时使用的一种特殊锁，确保在高并发下自增长字段的唯一性。</p>
                    
                    <div class="grid md:grid-cols-2 gap-6 mb-6">
                        <div class="bg-red-50 rounded-lg p-6 border-l-4 border-red-500">
                            <h3 class="font-bold text-lg flex items-center mb-3">
                                <i class="fas fa-project-diagram mr-2 text-red-500"></i>应用场景
                            </h3>
                            <ul class="space-y-2">
                                <li class="flex items-start">
                                    <i class="fas fa-exchange-alt text-red-400 mt-1 mr-2 text-sm"></i>
                                    <span><strong>并发插入：</strong>在高并发插入场景中，自增长锁保证每个事务获得唯一的自增长值。</span>
                                </li>
                            </ul>
                        </div>
                        <div class="bg-yellow-50 rounded-lg p-6 border-l-4 border-yellow-500">
                            <h3 class="font-bold text-lg flex items-center mb-3">
                                <i class="fas fa-exclamation-triangle mr-2 text-yellow-500"></i>影响
                            </h3>
                            <p>在并发插入高峰期，自增长锁可能成为瓶颈，特别是在分布式系统中。通过配置 <code class="px-2 py-1 bg-gray-100 rounded text-red-500">innodb_autoinc_lock_mode</code> 参数，可以调整自增长锁的行为，平衡性能和安全性。</p>
                        </div>
                    </div>
                </div>
            </div>
        </section>

        <!-- Gap Lock & Next-Key Lock -->
        <section id="gap-lock" class="mb-16">
            <div class="flex items-center mb-6">
                <span class="w-12 h-12 rounded-full bg-purple-100 flex items-center justify-center text-purple-600 text-xl mr-4">
                    <i class="fas fa-expand-alt"></i>
                </span>
                <h2 class="text-2xl font-bold text-gray-800">六、Gap 锁和 Next-Key 锁</h2>
            </div>
            <div class="bg-white rounded-xl shadow-md overflow-hidden">
                <div class="p-8">
                    <div class="grid md:grid-cols-2 gap-6 mb-6">
                        <div class="bg-purple-50 rounded-lg p-6 border-l-4 border-purple-500">
                            <h3 class="font-bold text-lg flex items-center mb-3">
                                <i class="fas fa-arrows-alt-h mr-2 text-purple-500"></i>Gap 锁
                            </h3>
                            <ul class="space-y-3">
                                <li>
                                    <div class="font-medium">描述</div>
                                    <p class="text-sm text-gray-600">Gap 锁是 InnoDB 为了解决幻读问题而引入的一种锁。它锁定某一范围内不存在的行，以防止其他事务在该范围内插入新行。</p>
                                </li>
                                <li>
                                    <div class="font-medium">应用场景</div>
                                    <p class="text-sm text-gray-600">主要用于可重复读（REPEATABLE READ）隔离级别下，避免幻读。</p>
                                </li>
                                <li>
                                    <div class="font-medium">影响</div>
                                    <p class="text-sm text-gray-600">Gap 锁可能导致一些不必要的锁竞争，尤其是在频繁插入数据的场景中。</p>
                                </li>
                            </ul>
                        </div>
                        <div class="bg-indigo-50 rounded-lg p-6 border-l-4 border-indigo-500">
                            <h3 class="font-bold text-lg flex items-center mb-3">
                                <i class="fas fa-link mr-2 text-indigo-500"></i>Next-Key 锁
                            </h3>
                            <ul class="space-y-3">
                                <li>
                                    <div class="font-medium">描述</div>
                                    <p class="text-sm text-gray-600">Next-Key 锁是行级锁和 Gap 锁的组合，锁定一行数据及其邻近的"空隙"区域，防止其他事务对该区域进行插入或删除操作。</p>
                                </li>
                                <li>
                                    <div class="font-medium">应用场景</div>
                                    <p class="text-sm text-gray-600">同样用于避免幻读问题，确保在可重复读隔离级别下的事务一致性。</p>
                                </li>
                                <li>
                                    <div class="font-medium">影响</div>
                                    <p class="text-sm text-gray-600">Next-Key 锁比单纯的行级锁更严格，可能导致更多的锁争用，影响并发性能。</p>
                                </li>
                            </ul>
                        </div>
                    </div>
                    
                    <div class="bg-blue-50 rounded-lg p-6 border-l-4 border-blue-500">
                        <h3 class="font-bold text-lg flex items-center mb-3">
                            <i class="fas fa-info-circle mr-2 text-blue-500"></i>补充说明
                        </h3>
                        <p>这两种锁都是 InnoDB 特有的锁机制，主要用于解决事务隔离级别中的幻读问题，理解它们的工作原理对于优化高并发数据库性能至关重要。</p>
                    </div>
                </div>
            </div>
        </section>

        <!-- Summary -->
        <section class="mb-16">
            <div class="bg-gradient-to-r from-blue-500 to-indigo-600 rounded-xl shadow-md p-8 text-white">
                <h2 class="text-2xl font-bold mb-4 flex items-center">
                    <i class="fas fa-lightbulb mr-3"></i>锁机制选择指南
                </h2>
                <div class="grid md:grid-cols-3 gap-6">
                    <div class="bg-white bg-opacity-20 p-4 rounded-lg">
                        <h3 class="font-bold mb-2">全局锁</h3>
                        <p class="text-sm opacity-90">适合全库备份等全局一致性要求场景</p>
                    </div>
                    <div class="bg-white bg-opacity-20 p-4 rounded-lg">
                        <h3 class="font-bold mb-2">表级锁</h3>
                        <p class="text-sm opacity-90">适合批量操作和表结构变更</p>
                    </div>
                    <div class="bg-white bg-opacity-20 p-4 rounded-lg">
                        <h3 class="font-bold mb-2">行级锁</h3>
                        <p class="text-sm opacity-90">适合高并发下的单行操作</p>
                    </div>
                </div>
            </div>
        </section>
    </main>

    <!-- Footer -->
    <footer class="bg-gray-900 text-gray-300 py-12 px-4">
        <div class="container mx-auto max-w-5xl">
            <div class="flex flex-col md:flex-row justify-between items-center">
                <div class="mb-4 md:mb-0">
                    <div class="text-2xl font-bold text-white mb-2">技术小馆</div>
                    <p class="text-gray-400">探索技术世界的知识宝库</p>
                </div>
                <div>
                    <a href="http://www.yuque.com/jtostring" class="text-blue-400 hover:text-blue-300 transition flex items-center">
                        <i class="fas fa-external-link-alt mr-2"></i>
                        访问技术小馆
                    </a>
                </div>
            </div>
            <div class="border-t border-gray-800 mt-8 pt-8 text-center text-sm text-gray-500">
                &copy; 2023 技术小馆. 保留所有权利.
            </div>
        </div>
    </footer>

    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <script>
        mermaid.initialize({
            startOnLoad: true,
            theme: 'default',
            flowchart: {
                useMaxWidth: true,
                htmlLabels: true,
                curve: 'basis'
            }
        });
    </script>
</body>
</html>